//
//  WXImgLoaderDefaultImpl.m
//  XZBProduct
//
//  Created by xzb on 2018/6/3.
//  Copyright © 2018年 xzb. All rights reserved.
//

#import "WXImgLoaderDefaultImpl.h"
#import <SDWebImage/UIImageView+WebCache.h>

@implementation WXImgLoaderDefaultImpl



#pragma mark WXImgLoaderProtocol



- (id<WXImageOperationProtocol>)downloadImageWithURL:(NSString *)url imageFrame:(CGRect)imageFrame userInfo:(NSDictionary *)userInfo completed:(void(^)(UIImage *image,  NSError *error, BOOL finished))completedBlock
{
    
    NSLog(@"-url------%@",url);
    
    if ([url hasPrefix:@"//"]) {
        
        url = [@"http:" stringByAppendingString:url];
        
    }
    
     return (id<WXImageOperationProtocol>)[[SDWebImageDownloader sharedDownloader] downloadImageWithURL:[NSURL URLWithString:url] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
        
    } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, BOOL finished) {
        
        if (completedBlock) {
            completedBlock(image,error,finished);
        }
    }];
    
}

@end
